<!DOCTYPE html>
<html lang="en">
<head>
    <script src="/static/js/dev.js"></script>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--bootstrap插件-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="/static/plugin/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/static/plugin/jo/joUI.css" rel="stylesheet"/>
    <!--字体插件-->
    <link href="/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/static/plugin/layui-2.4.3/css/layui.css" rel="stylesheet"/>
    <!--ztree-->
    <link href="/static/plugin/zTree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
    <!--common-->
    <link href="/static/css/common.css" rel="stylesheet"/>

    <title>数据库备份</title>
</head>
<body class="skin-default">

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12">
            <div class="container-fluid card">
                <div class="row">
                    <div class="col-xs-12 col-lg-12 col-md-12 col-sm-12">
                        <div class="form-group button-bar">
                            <button type="button" class="btn btn-warning" onclick="window.location.reload()">
                                <i class="fa fa-refresh" aria-hidden="true"></i>&nbsp;刷新
                            </button>
                            <button isShow="" type="button" class="btn btn-primary" onclick="backupTable()">
                                <i class="fa fa-download" aria-hidden="true"></i>&nbsp;表结构备份
                            </button>
                            <button isShow="" type="button" class="btn btn-info" onclick="recoverTable()">
                                <i class="fa fa-upload" aria-hidden="true"></i>&nbsp;表结构恢复
                            </button>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <table class="table table-bordered table-hover" id="mainList" dataUrl="{URL_CMS}cms/db/getTableList">
                                <col field="_seq" title="#" width="50px" align=""/>
                                <col field="id" title="表" width="40%" align=""/>
                                <col field="name" title="说明" width="50%" align=""/>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--配置信息-->
<script src="/static/js/config.js"></script>
<!--jquery-->
<script src="/static/plugin/jquery/jquery-3.3.1.js"></script>
<script src="/static/plugin/jquery/jquery.cookie.js"></script>
<!--bootstrap-->
<script src="/static/plugin/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="/static/plugin/other/html5shiv.js"></script>
<script src="/static/plugin/other/respond.min.js"></script>
<![endif]-->
<!--layui-->
<script src="/static/plugin/layui-2.4.3/layui.all.js"></script>
<!--ztree-->
<script src="/static/plugin/zTree/js/jquery.ztree.all.js"></script>
<!--上传插件-->
<link href="/static/plugin/webuploader-0.1.5/webuploader.css" rel="stylesheet">
<script src="/static/plugin/webuploader-0.1.5/webuploader.js"></script>
<script src="/static/js/upload.js"></script>
<!--common-->
<script src="/static/js/common.js"></script>
<!--jo-->
<script src="/static/plugin/jo/jo.js"></script>
<script src="/static/plugin/jo/jo-adapt.js"></script>
<script src="/static/plugin/jo/jo-page-view.js"></script>
<script src="/static/plugin/jo/jo-page-form.js"></script>
<script src="/static/plugin/jo/jo-listener.js"></script>
<script type="text/javascript">
    $(function(){
        joView.init({grid:$("#mainList"),PKName:"id",checkStyleWidth:"50px"});//初始化页面
    });
    //备份表结构
    var flag = true;
    function backupTable(){
        var ids = jo.getCheckBoxValue('id');
        if(!ids){
            jo.showTipsMsg('请勾选待备份的表');
            return;
        }
        if(flag){
            flag = false;
            window.setTimeout(function(){
                flag = true;//10秒后可以继续下载
            }, 10000);
            jo.post("{URL_CMS}cms/db/backupTable", {tableIds:ids});
        }else{
            jo.showTipsMsg('请勿频繁点击');
        }
    }
    //恢复表结构
    function recoverTable(){
        jo.uploadFile("{URL_CMS}cms/db/recoverTable", function (success, file, json) {
            if(success && json.code == 0){
                jo.showMsg("恢复成功!", {icon:1});
            }else{
                jo.showMsg("操作失败!", {icon:2});
            }
            jo.closeUploadDialog();
            joView.reloadCurrentPage();
        }, {UPLOAD_FILE_TYPES:'table',fileNumLimit:1})
    }
</script>

</body>
</html>
